package contest;

import java.io.*;

public class Itsourdelight {
	public static void main(String args[]) throws IOException{
		int[][] days = new int[3][2];
		for(int i=0;i<3;i++){
			for(int j=0;j<2;j++){
				days[i][j] = 0;
			}
		}
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int x = Integer.parseInt(br.readLine());
		for(int y=0;y<x;y++){
			String line =br.readLine();
			if(line == null)break;
			int i = Integer.parseInt(line.substring(0, line.indexOf(":")));
			int j = Integer.parseInt(line.substring(line.indexOf(":")+1, line.indexOf(" ")));
			int k = Integer.parseInt(line.substring(line.indexOf(" ")+1,line.length()));
			if(i>=11 && i <= 14){
				days[0][0]++;
				if((k-j >=0 && k-j <= 8) || (k-j >=-60 && k-j <= -52)){
					days[0][1]++;
				}
			}else if(i>=18 && i <= 20){
				days[1][0]++;
				if((k-j >=0 && k-j <= 8) || (k-j >=-60 && k-j <= -52)){
					days[1][1]++;
				}
			}else if((i>=21 && i <= 23 ) || (i>=0 && i <= 1 )){
				days[2][0]++;
				if((k-j >=0 && k-j <= 8) || (k-j >=-60 && k-j <= -52)){
					days[2][1]++;
				}
			}
		}
		br.readLine();
		if(days[0][0]==0)System.out.println("lunch no guest");
		else System.out.println("lunch " + (days[0][1]*100/days[0][0]) );
		if(days[1][0]==0)System.out.println("dinner no guest");
		else System.out.println("dinner " + (days[1][1]*100/days[1][0]) );
		if(days[2][0]==0)System.out.println("midnight no guest");
		else System.out.println("midnight " + (days[2][1]*100/days[2][0]) );
	}
}
